import 'package:citiesocial/_include.dart';
import 'package:citiesocial/ui/goods/goods_by_activity.dart';
import 'horizonal_goods.dart';

///
///首页最新闪购等活动
///
class IndexFlashCat extends StatelessWidget {
  final String title, url;
  final IndexEntity indexEntity;

  IndexFlashCat(this.title, {this.url, this.indexEntity}) : super();

  @override
  Widget build(BuildContext context) {
    final widgets = List<Widget>();
    if (indexEntity != null) {
      widgets.addAll([
        Container(
          child: Text(
            '$title',
            style: TextStyle(fontSize: 20.0, color: Colors.black),
          ),
          padding: EdgeInsets.all(10.0),
        ),
        Container(
          child: Configs.dividerMainColor,
          margin: EdgeInsets.symmetric(horizontal: 100.0),
        ),
      ]);
      if (indexEntity.list != null) {
        for (var activity in indexEntity.list) {
          widgets.addAll([
            LongGoodsItemIndex(
              activity,
              alarmable: true,
            ),
            HorizonalGoods(activity?.goods_list),
          ]);
        }
      }
      widgets.addAll([
        Container(
          child: Configs.dividerMainColor,
          margin: EdgeInsets.symmetric(horizontal: 20.0),
        ),
        SeeMore(
          onTap: () {
            Navigator.push(context,
                MaterialPageRoute(builder: (context) => GoodsByActivity(indexEntity.type)));
          },
        ),
        Container(
          decoration: BoxDecoration(
              shape: BoxShape.rectangle, color: Configs.background),
          height: 10.0,
        ),
      ]);
    }
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Center(
          child: Column(
            children: widgets,
          ),
        ),
      ],
    );
  }
}
